// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// An API that can be served by one or more Gateways.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Api {
    /// Output only. Resource name of the API.
    /// Format: projects/{project}/locations/global/apis/{api}
    pub name: std::string::String,

    /// Output only. Created time.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Updated time.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. Resource labels to represent user-provided metadata.
    /// Refer to cloud documentation on labels for more details.
    /// <https://cloud.google.com/compute/docs/labeling-resources>
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Optional. Display name.
    pub display_name: std::string::String,

    /// Optional. Immutable. The name of a Google Managed Service (
    /// <https://cloud.google.com/service-infrastructure/docs/glossary#managed>). If
    /// not specified, a new Service will automatically be created in the same
    /// project as this API.
    pub managed_service: std::string::String,

    /// Output only. State of the API.
    pub state: crate::model::api::State,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Api {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Api::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Api::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Api::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::Api::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::Api::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [labels][crate::model::Api::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [display_name][crate::model::Api::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [managed_service][crate::model::Api::managed_service].
    pub fn set_managed_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.managed_service = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Api::state].
    pub fn set_state<T: std::convert::Into<crate::model::api::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }
}

impl wkt::message::Message for Api {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.Api"
    }
}

/// Defines additional types related to [Api].
pub mod api {
    #[allow(unused_imports)]
    use super::*;

    /// All the possible API states.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// API does not have a state yet.
        Unspecified,
        /// API is being created.
        Creating,
        /// API is active.
        Active,
        /// API creation failed.
        Failed,
        /// API is being deleted.
        Deleting,
        /// API is being updated.
        Updating,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Active => std::option::Option::Some(2),
                Self::Failed => std::option::Option::Some(3),
                Self::Deleting => std::option::Option::Some(4),
                Self::Updating => std::option::Option::Some(5),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Active,
                3 => Self::Failed,
                4 => Self::Deleting,
                5 => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "ACTIVE" => Self::Active,
                "FAILED" => Self::Failed,
                "DELETING" => Self::Deleting,
                "UPDATING" => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Active => serializer.serialize_i32(2),
                Self::Failed => serializer.serialize_i32(3),
                Self::Deleting => serializer.serialize_i32(4),
                Self::Updating => serializer.serialize_i32(5),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.apigateway.v1.Api.State",
            ))
        }
    }
}

/// An API Configuration is a combination of settings for both the Managed
/// Service and Gateways serving this API Config.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ApiConfig {
    /// Output only. Resource name of the API Config.
    /// Format: projects/{project}/locations/global/apis/{api}/configs/{api_config}
    pub name: std::string::String,

    /// Output only. Created time.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Updated time.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. Resource labels to represent user-provided metadata.
    /// Refer to cloud documentation on labels for more details.
    /// <https://cloud.google.com/compute/docs/labeling-resources>
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Optional. Display name.
    pub display_name: std::string::String,

    /// Immutable. The Google Cloud IAM Service Account that Gateways serving this config
    /// should use to authenticate to other services. This may either be the
    /// Service Account's email
    /// (`{ACCOUNT_ID}@{PROJECT}.iam.gserviceaccount.com`) or its full resource
    /// name (`projects/{PROJECT}/accounts/{UNIQUE_ID}`). This is most often used
    /// when the service is a GCP resource such as a Cloud Run Service or an
    /// IAP-secured service.
    pub gateway_service_account: std::string::String,

    /// Output only. The ID of the associated Service Config (
    /// <https://cloud.google.com/service-infrastructure/docs/glossary#config>).
    pub service_config_id: std::string::String,

    /// Output only. State of the API Config.
    pub state: crate::model::api_config::State,

    /// Optional. OpenAPI specification documents. If specified, grpc_services and
    /// managed_service_configs must not be included.
    pub openapi_documents: std::vec::Vec<crate::model::api_config::OpenApiDocument>,

    /// Optional. gRPC service definition files. If specified, openapi_documents must
    /// not be included.
    pub grpc_services: std::vec::Vec<crate::model::api_config::GrpcServiceDefinition>,

    /// Optional. Service Configuration files. At least one must be included when using gRPC
    /// service definitions. See
    /// <https://cloud.google.com/endpoints/docs/grpc/grpc-service-config#service_configuration_overview>
    /// for the expected file contents.
    ///
    /// If multiple files are specified, the files are merged with the following
    /// rules:
    ///
    /// * All singular scalar fields are merged using "last one wins" semantics in
    ///   the order of the files uploaded.
    /// * Repeated fields are concatenated.
    /// * Singular embedded messages are merged using these rules for nested
    ///   fields.
    pub managed_service_configs: std::vec::Vec<crate::model::api_config::File>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ApiConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ApiConfig::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::ApiConfig::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::ApiConfig::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::ApiConfig::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::ApiConfig::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [labels][crate::model::ApiConfig::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [display_name][crate::model::ApiConfig::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [gateway_service_account][crate::model::ApiConfig::gateway_service_account].
    pub fn set_gateway_service_account<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.gateway_service_account = v.into();
        self
    }

    /// Sets the value of [service_config_id][crate::model::ApiConfig::service_config_id].
    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_config_id = v.into();
        self
    }

    /// Sets the value of [state][crate::model::ApiConfig::state].
    pub fn set_state<T: std::convert::Into<crate::model::api_config::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [openapi_documents][crate::model::ApiConfig::openapi_documents].
    pub fn set_openapi_documents<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::api_config::OpenApiDocument>,
    {
        use std::iter::Iterator;
        self.openapi_documents = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [grpc_services][crate::model::ApiConfig::grpc_services].
    pub fn set_grpc_services<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::api_config::GrpcServiceDefinition>,
    {
        use std::iter::Iterator;
        self.grpc_services = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [managed_service_configs][crate::model::ApiConfig::managed_service_configs].
    pub fn set_managed_service_configs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::api_config::File>,
    {
        use std::iter::Iterator;
        self.managed_service_configs = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ApiConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ApiConfig"
    }
}

/// Defines additional types related to [ApiConfig].
pub mod api_config {
    #[allow(unused_imports)]
    use super::*;

    /// A lightweight description of a file.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct File {
        /// The file path (full or relative path). This is typically the path of the
        /// file when it is uploaded.
        pub path: std::string::String,

        /// The bytes that constitute the file.
        pub contents: ::bytes::Bytes,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl File {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [path][crate::model::api_config::File::path].
        pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.path = v.into();
            self
        }

        /// Sets the value of [contents][crate::model::api_config::File::contents].
        pub fn set_contents<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
            self.contents = v.into();
            self
        }
    }

    impl wkt::message::Message for File {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.apigateway.v1.ApiConfig.File"
        }
    }

    /// An OpenAPI Specification Document describing an API.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct OpenApiDocument {
        /// The OpenAPI Specification document file.
        pub document: std::option::Option<crate::model::api_config::File>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl OpenApiDocument {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [document][crate::model::api_config::OpenApiDocument::document].
        pub fn set_document<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::api_config::File>,
        {
            self.document = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [document][crate::model::api_config::OpenApiDocument::document].
        pub fn set_or_clear_document<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::api_config::File>,
        {
            self.document = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for OpenApiDocument {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.apigateway.v1.ApiConfig.OpenApiDocument"
        }
    }

    /// A gRPC service definition.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct GrpcServiceDefinition {
        /// Input only. File descriptor set, generated by protoc.
        ///
        /// To generate, use protoc with imports and source info included.
        /// For an example test.proto file, the following command would put the value
        /// in a new file named out.pb.
        ///
        /// $ protoc --include_imports --include_source_info test.proto -o out.pb
        pub file_descriptor_set: std::option::Option<crate::model::api_config::File>,

        /// Optional. Uncompiled proto files associated with the descriptor set, used for
        /// display purposes (server-side compilation is not supported). These
        /// should match the inputs to 'protoc' command used to generate
        /// file_descriptor_set.
        pub source: std::vec::Vec<crate::model::api_config::File>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl GrpcServiceDefinition {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [file_descriptor_set][crate::model::api_config::GrpcServiceDefinition::file_descriptor_set].
        pub fn set_file_descriptor_set<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::api_config::File>,
        {
            self.file_descriptor_set = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [file_descriptor_set][crate::model::api_config::GrpcServiceDefinition::file_descriptor_set].
        pub fn set_or_clear_file_descriptor_set<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::api_config::File>,
        {
            self.file_descriptor_set = v.map(|x| x.into());
            self
        }

        /// Sets the value of [source][crate::model::api_config::GrpcServiceDefinition::source].
        pub fn set_source<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::api_config::File>,
        {
            use std::iter::Iterator;
            self.source = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for GrpcServiceDefinition {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.apigateway.v1.ApiConfig.GrpcServiceDefinition"
        }
    }

    /// All the possible API Config states.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// API Config does not have a state yet.
        Unspecified,
        /// API Config is being created and deployed to the API Controller.
        Creating,
        /// API Config is ready for use by Gateways.
        Active,
        /// API Config creation failed.
        Failed,
        /// API Config is being deleted.
        Deleting,
        /// API Config is being updated.
        Updating,
        /// API Config settings are being activated in downstream systems.
        /// API Configs in this state cannot be used by Gateways.
        Activating,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Active => std::option::Option::Some(2),
                Self::Failed => std::option::Option::Some(3),
                Self::Deleting => std::option::Option::Some(4),
                Self::Updating => std::option::Option::Some(5),
                Self::Activating => std::option::Option::Some(6),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::Activating => std::option::Option::Some("ACTIVATING"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Active,
                3 => Self::Failed,
                4 => Self::Deleting,
                5 => Self::Updating,
                6 => Self::Activating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "ACTIVE" => Self::Active,
                "FAILED" => Self::Failed,
                "DELETING" => Self::Deleting,
                "UPDATING" => Self::Updating,
                "ACTIVATING" => Self::Activating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Active => serializer.serialize_i32(2),
                Self::Failed => serializer.serialize_i32(3),
                Self::Deleting => serializer.serialize_i32(4),
                Self::Updating => serializer.serialize_i32(5),
                Self::Activating => serializer.serialize_i32(6),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.apigateway.v1.ApiConfig.State",
            ))
        }
    }
}

/// A Gateway is an API-aware HTTP proxy. It performs API-Method and/or
/// API-Consumer specific actions based on an API Config such as authentication,
/// policy enforcement, and backend selection.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Gateway {
    /// Output only. Resource name of the Gateway.
    /// Format: projects/{project}/locations/{location}/gateways/{gateway}
    pub name: std::string::String,

    /// Output only. Created time.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Updated time.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. Resource labels to represent user-provided metadata.
    /// Refer to cloud documentation on labels for more details.
    /// <https://cloud.google.com/compute/docs/labeling-resources>
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Optional. Display name.
    pub display_name: std::string::String,

    /// Required. Resource name of the API Config for this Gateway.
    /// Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}
    pub api_config: std::string::String,

    /// Output only. The current state of the Gateway.
    pub state: crate::model::gateway::State,

    /// Output only. The default API Gateway host name of the form
    /// `{gateway_id}-{hash}.{region_code}.gateway.dev`.
    pub default_hostname: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Gateway {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Gateway::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Gateway::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Gateway::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::Gateway::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::Gateway::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [labels][crate::model::Gateway::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [display_name][crate::model::Gateway::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [api_config][crate::model::Gateway::api_config].
    pub fn set_api_config<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_config = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Gateway::state].
    pub fn set_state<T: std::convert::Into<crate::model::gateway::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [default_hostname][crate::model::Gateway::default_hostname].
    pub fn set_default_hostname<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.default_hostname = v.into();
        self
    }
}

impl wkt::message::Message for Gateway {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.Gateway"
    }
}

/// Defines additional types related to [Gateway].
pub mod gateway {
    #[allow(unused_imports)]
    use super::*;

    /// All the possible Gateway states.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Gateway does not have a state yet.
        Unspecified,
        /// Gateway is being created.
        Creating,
        /// Gateway is running and ready for requests.
        Active,
        /// Gateway creation failed.
        Failed,
        /// Gateway is being deleted.
        Deleting,
        /// Gateway is being updated.
        Updating,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Active => std::option::Option::Some(2),
                Self::Failed => std::option::Option::Some(3),
                Self::Deleting => std::option::Option::Some(4),
                Self::Updating => std::option::Option::Some(5),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Active,
                3 => Self::Failed,
                4 => Self::Deleting,
                5 => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "ACTIVE" => Self::Active,
                "FAILED" => Self::Failed,
                "DELETING" => Self::Deleting,
                "UPDATING" => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Active => serializer.serialize_i32(2),
                Self::Failed => serializer.serialize_i32(3),
                Self::Deleting => serializer.serialize_i32(4),
                Self::Updating => serializer.serialize_i32(5),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.apigateway.v1.Gateway.State",
            ))
        }
    }
}

/// Request message for ApiGatewayService.ListGateways
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListGatewaysRequest {
    /// Required. Parent resource of the Gateway, of the form:
    /// `projects/*/locations/*`
    pub parent: std::string::String,

    /// Page size.
    pub page_size: i32,

    /// Page token.
    pub page_token: std::string::String,

    /// Filter.
    pub filter: std::string::String,

    /// Order by parameters.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListGatewaysRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListGatewaysRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListGatewaysRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListGatewaysRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListGatewaysRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListGatewaysRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListGatewaysRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ListGatewaysRequest"
    }
}

/// Response message for ApiGatewayService.ListGateways
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListGatewaysResponse {
    /// Gateways.
    pub gateways: std::vec::Vec<crate::model::Gateway>,

    /// Next page token.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable_locations: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListGatewaysResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [gateways][crate::model::ListGatewaysResponse::gateways].
    pub fn set_gateways<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Gateway>,
    {
        use std::iter::Iterator;
        self.gateways = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListGatewaysResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable_locations][crate::model::ListGatewaysResponse::unreachable_locations].
    pub fn set_unreachable_locations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable_locations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListGatewaysResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ListGatewaysResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListGatewaysResponse {
    type PageItem = crate::model::Gateway;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.gateways
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for ApiGatewayService.GetGateway
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetGatewayRequest {
    /// Required. Resource name of the form:
    /// `projects/*/locations/*/gateways/*`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetGatewayRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetGatewayRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetGatewayRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.GetGatewayRequest"
    }
}

/// Request message for ApiGatewayService.CreateGateway
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateGatewayRequest {
    /// Required. Parent resource of the Gateway, of the form:
    /// `projects/*/locations/*`
    pub parent: std::string::String,

    /// Required. Identifier to assign to the Gateway. Must be unique within scope of
    /// the parent resource.
    pub gateway_id: std::string::String,

    /// Required. Gateway resource.
    pub gateway: std::option::Option<crate::model::Gateway>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateGatewayRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateGatewayRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [gateway_id][crate::model::CreateGatewayRequest::gateway_id].
    pub fn set_gateway_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.gateway_id = v.into();
        self
    }

    /// Sets the value of [gateway][crate::model::CreateGatewayRequest::gateway].
    pub fn set_gateway<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Gateway>,
    {
        self.gateway = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [gateway][crate::model::CreateGatewayRequest::gateway].
    pub fn set_or_clear_gateway<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Gateway>,
    {
        self.gateway = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateGatewayRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.CreateGatewayRequest"
    }
}

/// Request message for ApiGatewayService.UpdateGateway
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateGatewayRequest {
    /// Field mask is used to specify the fields to be overwritten in the
    /// Gateway resource by the update.
    /// The fields specified in the update_mask are relative to the resource, not
    /// the full request. A field will be overwritten if it is in the mask. If the
    /// user does not provide a mask then all fields will be overwritten.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. Gateway resource.
    pub gateway: std::option::Option<crate::model::Gateway>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateGatewayRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdateGatewayRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateGatewayRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [gateway][crate::model::UpdateGatewayRequest::gateway].
    pub fn set_gateway<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Gateway>,
    {
        self.gateway = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [gateway][crate::model::UpdateGatewayRequest::gateway].
    pub fn set_or_clear_gateway<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Gateway>,
    {
        self.gateway = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateGatewayRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.UpdateGatewayRequest"
    }
}

/// Request message for ApiGatewayService.DeleteGateway
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteGatewayRequest {
    /// Required. Resource name of the form:
    /// `projects/*/locations/*/gateways/*`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteGatewayRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteGatewayRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteGatewayRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.DeleteGatewayRequest"
    }
}

/// Request message for ApiGatewayService.ListApis
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListApisRequest {
    /// Required. Parent resource of the API, of the form:
    /// `projects/*/locations/global`
    pub parent: std::string::String,

    /// Page size.
    pub page_size: i32,

    /// Page token.
    pub page_token: std::string::String,

    /// Filter.
    pub filter: std::string::String,

    /// Order by parameters.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListApisRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListApisRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListApisRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListApisRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListApisRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListApisRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListApisRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ListApisRequest"
    }
}

/// Response message for ApiGatewayService.ListApis
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListApisResponse {
    /// APIs.
    pub apis: std::vec::Vec<crate::model::Api>,

    /// Next page token.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable_locations: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListApisResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [apis][crate::model::ListApisResponse::apis].
    pub fn set_apis<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Api>,
    {
        use std::iter::Iterator;
        self.apis = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListApisResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable_locations][crate::model::ListApisResponse::unreachable_locations].
    pub fn set_unreachable_locations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable_locations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListApisResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ListApisResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListApisResponse {
    type PageItem = crate::model::Api;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.apis
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for ApiGatewayService.GetApi
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetApiRequest {
    /// Required. Resource name of the form:
    /// `projects/*/locations/global/apis/*`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetApiRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetApiRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetApiRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.GetApiRequest"
    }
}

/// Request message for ApiGatewayService.CreateApi
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateApiRequest {
    /// Required. Parent resource of the API, of the form:
    /// `projects/*/locations/global`
    pub parent: std::string::String,

    /// Required. Identifier to assign to the API. Must be unique within scope of
    /// the parent resource.
    pub api_id: std::string::String,

    /// Required. API resource.
    pub api: std::option::Option<crate::model::Api>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateApiRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateApiRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [api_id][crate::model::CreateApiRequest::api_id].
    pub fn set_api_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_id = v.into();
        self
    }

    /// Sets the value of [api][crate::model::CreateApiRequest::api].
    pub fn set_api<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Api>,
    {
        self.api = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [api][crate::model::CreateApiRequest::api].
    pub fn set_or_clear_api<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Api>,
    {
        self.api = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateApiRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.CreateApiRequest"
    }
}

/// Request message for ApiGatewayService.UpdateApi
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateApiRequest {
    /// Field mask is used to specify the fields to be overwritten in the
    /// Api resource by the update.
    /// The fields specified in the update_mask are relative to the resource, not
    /// the full request. A field will be overwritten if it is in the mask. If the
    /// user does not provide a mask then all fields will be overwritten.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. API resource.
    pub api: std::option::Option<crate::model::Api>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateApiRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdateApiRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateApiRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [api][crate::model::UpdateApiRequest::api].
    pub fn set_api<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Api>,
    {
        self.api = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [api][crate::model::UpdateApiRequest::api].
    pub fn set_or_clear_api<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Api>,
    {
        self.api = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateApiRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.UpdateApiRequest"
    }
}

/// Request message for ApiGatewayService.DeleteApi
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteApiRequest {
    /// Required. Resource name of the form:
    /// `projects/*/locations/global/apis/*`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteApiRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteApiRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteApiRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.DeleteApiRequest"
    }
}

/// Request message for ApiGatewayService.ListApiConfigs
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListApiConfigsRequest {
    /// Required. Parent resource of the API Config, of the form:
    /// `projects/*/locations/global/apis/*`
    pub parent: std::string::String,

    /// Page size.
    pub page_size: i32,

    /// Page token.
    pub page_token: std::string::String,

    /// Filter.
    pub filter: std::string::String,

    /// Order by parameters.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListApiConfigsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListApiConfigsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListApiConfigsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListApiConfigsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListApiConfigsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListApiConfigsRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListApiConfigsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ListApiConfigsRequest"
    }
}

/// Response message for ApiGatewayService.ListApiConfigs
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListApiConfigsResponse {
    /// API Configs.
    pub api_configs: std::vec::Vec<crate::model::ApiConfig>,

    /// Next page token.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable_locations: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListApiConfigsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [api_configs][crate::model::ListApiConfigsResponse::api_configs].
    pub fn set_api_configs<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ApiConfig>,
    {
        use std::iter::Iterator;
        self.api_configs = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListApiConfigsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable_locations][crate::model::ListApiConfigsResponse::unreachable_locations].
    pub fn set_unreachable_locations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable_locations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListApiConfigsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.ListApiConfigsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListApiConfigsResponse {
    type PageItem = crate::model::ApiConfig;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.api_configs
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for ApiGatewayService.GetApiConfig
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetApiConfigRequest {
    /// Required. Resource name of the form:
    /// `projects/*/locations/global/apis/*/configs/*`
    pub name: std::string::String,

    /// Specifies which fields of the API Config are returned in the response.
    /// Defaults to `BASIC` view.
    pub view: crate::model::get_api_config_request::ConfigView,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetApiConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetApiConfigRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [view][crate::model::GetApiConfigRequest::view].
    pub fn set_view<T: std::convert::Into<crate::model::get_api_config_request::ConfigView>>(
        mut self,
        v: T,
    ) -> Self {
        self.view = v.into();
        self
    }
}

impl wkt::message::Message for GetApiConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.GetApiConfigRequest"
    }
}

/// Defines additional types related to [GetApiConfigRequest].
pub mod get_api_config_request {
    #[allow(unused_imports)]
    use super::*;

    /// Enum to control which fields should be included in the response.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ConfigView {
        Unspecified,
        /// Do not include configuration source files.
        Basic,
        /// Include configuration source files.
        Full,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [ConfigView::value] or
        /// [ConfigView::name].
        UnknownValue(config_view::UnknownValue),
    }

    #[doc(hidden)]
    pub mod config_view {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl ConfigView {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Basic => std::option::Option::Some(1),
                Self::Full => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("CONFIG_VIEW_UNSPECIFIED"),
                Self::Basic => std::option::Option::Some("BASIC"),
                Self::Full => std::option::Option::Some("FULL"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for ConfigView {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for ConfigView {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for ConfigView {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Basic,
                2 => Self::Full,
                _ => Self::UnknownValue(config_view::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for ConfigView {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "CONFIG_VIEW_UNSPECIFIED" => Self::Unspecified,
                "BASIC" => Self::Basic,
                "FULL" => Self::Full,
                _ => Self::UnknownValue(config_view::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for ConfigView {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Basic => serializer.serialize_i32(1),
                Self::Full => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for ConfigView {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ConfigView>::new(
                ".google.cloud.apigateway.v1.GetApiConfigRequest.ConfigView",
            ))
        }
    }
}

/// Request message for ApiGatewayService.CreateApiConfig
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateApiConfigRequest {
    /// Required. Parent resource of the API Config, of the form:
    /// `projects/*/locations/global/apis/*`
    pub parent: std::string::String,

    /// Required. Identifier to assign to the API Config. Must be unique within scope of
    /// the parent resource.
    pub api_config_id: std::string::String,

    /// Required. API resource.
    pub api_config: std::option::Option<crate::model::ApiConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateApiConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateApiConfigRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [api_config_id][crate::model::CreateApiConfigRequest::api_config_id].
    pub fn set_api_config_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_config_id = v.into();
        self
    }

    /// Sets the value of [api_config][crate::model::CreateApiConfigRequest::api_config].
    pub fn set_api_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ApiConfig>,
    {
        self.api_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [api_config][crate::model::CreateApiConfigRequest::api_config].
    pub fn set_or_clear_api_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ApiConfig>,
    {
        self.api_config = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateApiConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.CreateApiConfigRequest"
    }
}

/// Request message for ApiGatewayService.UpdateApiConfig
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateApiConfigRequest {
    /// Field mask is used to specify the fields to be overwritten in the
    /// ApiConfig resource by the update.
    /// The fields specified in the update_mask are relative to the resource, not
    /// the full request. A field will be overwritten if it is in the mask. If the
    /// user does not provide a mask then all fields will be overwritten.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. API Config resource.
    pub api_config: std::option::Option<crate::model::ApiConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateApiConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdateApiConfigRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateApiConfigRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [api_config][crate::model::UpdateApiConfigRequest::api_config].
    pub fn set_api_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ApiConfig>,
    {
        self.api_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [api_config][crate::model::UpdateApiConfigRequest::api_config].
    pub fn set_or_clear_api_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ApiConfig>,
    {
        self.api_config = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateApiConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.UpdateApiConfigRequest"
    }
}

/// Request message for ApiGatewayService.DeleteApiConfig
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteApiConfigRequest {
    /// Required. Resource name of the form:
    /// `projects/*/locations/global/apis/*/configs/*`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteApiConfigRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteApiConfigRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteApiConfigRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.DeleteApiConfigRequest"
    }
}

/// Represents the metadata of the long-running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// Output only. The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Server-defined resource path for the target of the operation.
    pub target: std::string::String,

    /// Output only. Name of the verb executed by the operation.
    pub verb: std::string::String,

    /// Output only. Human-readable status of the operation, if any.
    pub status_message: std::string::String,

    /// Output only. Identifies whether the user has requested cancellation
    /// of the operation. Operations that have successfully been cancelled
    /// have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
    /// corresponding to `Code.CANCELLED`.
    ///
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub requested_cancellation: bool,

    /// Output only. API version used to start the operation.
    pub api_version: std::string::String,

    /// Output only. Diagnostics generated during processing of configuration source files.
    pub diagnostics: std::vec::Vec<crate::model::operation_metadata::Diagnostic>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::OperationMetadata::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.verb = v.into();
        self
    }

    /// Sets the value of [status_message][crate::model::OperationMetadata::status_message].
    pub fn set_status_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.status_message = v.into();
        self
    }

    /// Sets the value of [requested_cancellation][crate::model::OperationMetadata::requested_cancellation].
    pub fn set_requested_cancellation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.requested_cancellation = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }

    /// Sets the value of [diagnostics][crate::model::OperationMetadata::diagnostics].
    pub fn set_diagnostics<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::operation_metadata::Diagnostic>,
    {
        use std::iter::Iterator;
        self.diagnostics = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.apigateway.v1.OperationMetadata"
    }
}

/// Defines additional types related to [OperationMetadata].
pub mod operation_metadata {
    #[allow(unused_imports)]
    use super::*;

    /// Diagnostic information from configuration processing.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Diagnostic {
        /// Location of the diagnostic.
        pub location: std::string::String,

        /// The diagnostic message.
        pub message: std::string::String,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Diagnostic {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [location][crate::model::operation_metadata::Diagnostic::location].
        pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.location = v.into();
            self
        }

        /// Sets the value of [message][crate::model::operation_metadata::Diagnostic::message].
        pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.message = v.into();
            self
        }
    }

    impl wkt::message::Message for Diagnostic {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.apigateway.v1.OperationMetadata.Diagnostic"
        }
    }
}
